home *** CD-ROM | disk | FTP | other *** search
/ Eagles Nest BBS 1 / Eagles_Nest_Mac_Collection_Disc_1.TOAST / CPs & Extensions / SuitC214p3up / Suitcase 2.1.4p3 Update / For THINK TCL Developers next >
Text File  |  1993-11-30  |  5KB  |  79 lines

  1. For software developers using the THINK Class Library (TCL)
  2. to implement pop-up font menus or font menus with custom MDEFs
  3. ------------------------------------------------------------
  4.  
  5. The scheme used by TCL to implement pop-up menus and/or custom MDEFs is incompatible with Suitcase for font menus.  The changes described below will make TCL pop-up and/or custom-MDEF font menus compatible with Suitcase and should have no adverse affects nor introduce incompatibilities with anything else.  Note that there is no compatibility problem except for font menus which are pop-up menus or which have a custom MDEF that you develop or both.
  6.  
  7. Summary:  TCL installs an MDEF "hook" that assumes that no other software (such as Suitcase) will also install such a hook after TCL's hook is installed.  The changes below remove reliance on that assumption.
  8.  
  9. These changes are specified with respect to TCL 1.1.3, but the same or very similar changes should be applicable to earlier versions.
  10.  
  11.  
  12. I.  Font popup menus.
  13.  
  14. If you want to use TCL’s "hook" feature which widens pop-up menus to acommodate a down-arrow, you can make the following changes for Suitcase compatibility if you have pop-up font menus.  (If you don't want the hook feature you can just remove the #define __INSTALL_MENU_HOOK__ in CStdPopupPane.cp, in which case the following changes are not required.   Regardless, if you have a font menu with a custom MDEF, see the second section of this document.)
  15.  
  16. In CStdPopupPane.h, change struct tMenuHook's first field from
  17.         short   jmp;
  18. to
  19.         short   bsr;
  20. and add the following additional field at the end of the struct:
  21.         long    hookCode[3];
  22.  
  23. In CStdPopupPane.cp, change the definition near the top of the file from:
  24.  
  25. static pascal void MenuProc( short message, MenuHandle menu, Rect *menuRect,
  26.                                         Point hitPt, short *whichItem);
  27.  
  28. to add a new final argument as follows:
  29.  
  30. static pascal void MenuProc( short message, MenuHandle menu, Rect *menuRect,
  31.                                         Point hitPt, short *whichItem,
  32.                                         Handle realMenuProc);
  33.  
  34. Change three code lines in CStdPopupPane::HookMenu from:
  35.         (**theHook).jmp = 0x4EF9;               /* JMP instruction */
  36.         (**theHook).addr =  (long) MenuProc;
  37.         (**theHook).realMenuProc = (**menu).menuProc;   
  38. to expand them to the following:
  39.         (**theHook).bsr = 0x6108;                                   /* Bsr @0 instruction */
  40.         (**theHook).addr = (long) MenuProc; /* (no change) */
  41.         (**theHook).realMenuProc = (**menu).menuProc; /* (no change) */
  42.         (**theHook).hookCode[0] = 0x205F201F;   /* @0: Move.L (SP)+,A0
  43.                                                                                     Move.L (SP)+,D0 */
  44.         (**theHook).hookCode[1] = 0x22582F10;   /*       Move.L (A0)+,A1
  45.                                                                                     Move..L (A0),-(SP) */
  46.         (**theHook).hookCode[2] = 0x2F004ED1;   /*        Move.L D0,-(SP)
  47.                                                                                     Jmp (A1) */
  48.  
  49. Change the MenuProc function at the end of the source file as follows:
  50.  
  51. Add a new final argument:
  52. static pascal void MenuProc( short message, MenuHandle menu, Rect *menuRect,
  53.                         Point hitPt, short *whichItem, Handle realMenuProc)
  54.  
  55. Remove these two lines:
  56.         tMenuHookHndl   menuHook;
  57.         Handle          realMenuProc;
  58. and remove these two lines:                                             
  59.         menuHook = (tMenuHookHndl) (**menu).menuProc;
  60.         realMenuProc = (**menuHook).realMenuProc;
  61.  
  62. You might also want to change a comment in the file regarding the source of the "hook" logic — do a Find on "technique".
  63.  
  64.  
  65.  
  66. II.  Font menus with custom MDEFs.
  67.  
  68. (1) TCL documentation (THINK Class Library Guide Version 6, p. 318) says that your MDEF resource should be 10 bytes long with the following contents (hex):
  69. 4EF9 0000 0000 0000 0000
  70.  
  71. Instead, make it 22 bytes long with the following contents (hex):
  72. 6108 0000 0000 0000 0000 205F 201F 2258 2F10 2F00 4ED1
  73. (For a disassembly of this code, see the comments in the suggested changes to CStdPopupPane::HookMenu in Part I above.)
  74.  
  75. (2) Alter GenericMDEF.h and GenericMDEF.cp (or .c if you're using a THINK C earlier than 6.0) to add the following additional argument as the last argument to GenericMDEF (it will follow the previously last argument, whichItem):
  76.                 CMenuDefProc *theMenuDefProc
  77.  
  78. Alter the definition of GenericMDEF in GenericMDEF.cp (or .c) to remove the declarations of the two local variables theMDEF and theMenuDefProc (the latter is now an argument to the function per the preceding paragraph), and to remove the first two assignment statements.  In sum, after the change, GenericMDEF will take an additional argument (which was formerly a local variable), have no local variables, and execute only a switch statement.
  79.